using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using Microsoft.Ccr.Core;
using Microsoft.Dss.Core.DsspHttp;
using Microsoft.Dss.Core.Attributes;
using Microsoft.Dss.ServiceModel.Dssp;
using Microsoft.Dss.ServiceModel.DsspServiceBase;
using W3C.Soap;

namespace JaguarControl
{
    #region Contract Identifier
    /// <summary>
    /// JaguarControl contract class
    /// </summary>
    public sealed class Contract
    {
        /// <summary> Contract Identifier
        /// DSS contract identifer for JaguarControl
        /// </summary>
        [DataMember]
        public const string Identifier = "http://erobots.jcepeda/2011/08/jaguarcontrol.html";
    }
    #endregion 

    /// <summary> Operations Port
    /// JaguarControl main operations port
    /// </summary>
    [ServicePort]
    class JaguarControlOperations : PortSet<DsspDefaultLookup, DsspDefaultDrop, Get, Replace,
        Update, WatchDogUpdate, HttpGet, Subscribe>
    {
    }

    #region Operations Ports Classes
    /// <summary>
    /// 
    /// </summary>
    public class Replace : Replace<JaguarControlState, PortSet<DefaultReplaceResponseType, Fault>>
    {
        public Replace(JaguarControlState body)
            : base(body)
        { }

        public Replace()
        { }
    }

    /// <summary>
    /// 
    /// </summary>
    public class Update : Update<JaguarControlState, PortSet<DefaultReplaceResponseType, Fault>>
    {
    }

    /// <summary>
    /// JaguarControl get operation
    /// </summary>
    public class Get : Get<GetRequestType, PortSet<JaguarControlState, Fault>>
    {
        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        public Get()
        {
        }

        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        /// <param name="body">the request message body</param>
        public Get(GetRequestType body)
            : base(body)
        {
        }

        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        /// <param name="body">the request message body</param>
        /// <param name="responsePort">the response port for the request</param>
        public Get(GetRequestType body, PortSet<JaguarControlState, Fault> responsePort)
            : base(body, responsePort)
        {
        }
    }

    /// <summary>
    /// Imported from the Pioneer Control Robot.
    /// </summary>
    [Description("Provides an update to the watchdog state.")]
    class WatchDogUpdate : Update<WatchDogUpdateRequest, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public WatchDogUpdate(WatchDogUpdateRequest body)
            : base(body)
        { }

        public WatchDogUpdate()
        { }
    }
    [DataContract]
    public class WatchDogUpdateRequest
    {
        private DateTime _timeStamp;

        [DataMember]
        [Description("Indicates the time of the reading (in ms).")]
        public DateTime TimeStamp
        {
            get { return _timeStamp; }
            set { _timeStamp = value; }
        }

        public WatchDogUpdateRequest(DateTime timeStamp)
        {
            TimeStamp = timeStamp;
        }

        public WatchDogUpdateRequest()
        { }
    }

    /// <summary>
    /// JaguarControl subscribe operation
    /// </summary>
    public class Subscribe : Subscribe<SubscribeRequestType, PortSet<SubscribeResponseType, Fault>>
    {
        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        public Subscribe()
        {
        }

        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        /// <param name="body">the request message body</param>
        public Subscribe(SubscribeRequestType body)
            : base(body)
        {
        }

        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        /// <param name="body">the request message body</param>
        /// <param name="responsePort">the response port for the request</param>
        public Subscribe(SubscribeRequestType body, PortSet<SubscribeResponseType, Fault> responsePort)
            : base(body, responsePort)
        {
        }
    }
    #endregion

    public class FromWinformsEvents : Port<FromWinformMsg> { }
    public class FromWinformMsg
    {
        public enum MsgEnum
        {
            Init,
            Close,
            //ConsoleTest  //-->This MsgEnum is for testing the messaging from MainForm to SimJaguarsControl.cs
            //   there is a switch case in OnWinformMessageHandler for console printing.
        }

        private MsgEnum _command;
        public MsgEnum Command
        {
            get { return _command; }
            set { _command = value; }
        }

        public FromWinformMsg(MsgEnum command)
        {
            _command = command;
        }

        private bool _manualcontrol;
        public bool ManualControl
        {
            get { return _manualcontrol; }
            set { _manualcontrol = value; }
        }

        private double _battery;
        public double BatteryVoltage
        {
            get { return _battery; }
            set { _battery = value; }
        }

        public enum BatteryEnum
        {
            CRITICAL,
            LOW, 
            OK
        }

        private BatteryEnum _battstate;
        public BatteryEnum BatteryState
        {
            get { return _battstate; }
            set { _battstate = value; }
        }

        private bool _stuckdetect;
        public bool StuckDetect
        {
            get { return _stuckdetect; }
            set { _stuckdetect = value; }
        }

        private bool _tempdetect;
        public bool TemperatureDetect
        {
            get { return _tempdetect; }
            set { _tempdetect = value; }
        }

        private MainForm.EncoderRecord _encodersdata;
        public MainForm.EncoderRecord EncodersData
        {
            get { return _encodersdata; }
            set { _encodersdata = value; }
        }

        private MainForm.GPSRecord _gpsdata;
        public MainForm.GPSRecord GPSData
        {
            get { return _gpsdata; }
            set { _gpsdata = value; }
        }

        private MainForm.IMURecord _imudata;
        public MainForm.IMURecord IMUData
        {
            get { return _imudata; }
            set { _imudata = value; }
        }

        private int[] _laserdata;
        public int[] LaserData
        {
            get { return _laserdata; }
            set { _laserdata = value; }
        }

        private Image _webcamdata;
        public Image CameraData
        {
            get { return _webcamdata; }
            set { _webcamdata = value; }
        } 

        private Bitmap _map;
        public Bitmap Map
        {
            get { return _map; }
            set { _map = value; }
        } 
        
    }
}


